<?php echo $this->fetch('header.html'); ?>
<?php if ($_GET['act'] == 'ajax_list'): ?>
<table cellspacing="0" width="100%" class="dataTable" id="deliveryList">
<thead>
<tr class="tatr1"><td>订单编号</td><td>运单号</td><td>收件人</td><td>收件人手机</td><td>主单/批次号</td><td>麻袋/包裹货号</td><td>报关单号</td><td>添加时间</td></tr>
</thead>
<?php $_from = $this->_var['order_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'order');if (count($_from)):
    foreach ($_from AS $this->_var['order']):
?>
<tbody>
  <tr class="tatr2"><td><?php echo $this->_var['order']['order_sn']; ?></td><td><?php echo $this->_var['order']['yundanhao']; ?></td><td><?php echo $this->_var['order']['txtRece_name']; ?></td><td><?php echo $this->_var['order']['txtRece_mobilephone']; ?></td><td><?php echo $this->_var['order']['zhudanNo']; ?></td><td><?php echo $this->_var['order']['baoguoNo']; ?></td><td><?php echo $this->_var['order']['baoguanNo']; ?></td><td><?php echo local_date("Y-m-d H:i:s",$this->_var['order']['addtime']); ?></td></tr>
</tbody>
<?php endforeach; else: ?>
  <tr><td colspan="8" style="padding:8px; color:#F00; text-align:center; font-size:14px;">没有符合条件的记录</td></tr>
<?php endif; unset($_from); ?><?php $this->pop_vars();; ?>
</table>
<div id="dataFuncs">
  <div class="pageLinks"><?php echo $this->fetch('page.bottom.html'); ?></div>
</div>
<script type="text/javascript">
$(window.parent.document).find("#rightMain").load(function(){ 
var main = $(window.parent.document).find("#rightMain"); 
var thisheight = $(document).height(); 
main.height(thisheight); 
});
</script>
<?php else: ?>
<script type="text/javascript" src="<?php echo SITE_URL."/includes/libraries/javascript/" . 'datePicker/WdatePicker.js'; ?>" charset="utf-8"></script>
<style>
.kdorder_add {background:#dddddd}
.kdorder_add td{padding:8px; background:#FFF}
.kdorder_add .title_h1 {font-size:14px; color:#333; background:#f0f7ff; font-family:'Microsoft Yahei'; width:150px;}
.kdorder_add .title_h1 em{font-style:normal; color:#F00; margin-right:5px}
.kdorder_add .select_class {border: 1px #CCC solid;height: 30px;border-radius:2px}
.inputBorder{border: 1px #CCC solid;height: 20px;line-height: 20px;padding: 4px 8px; width:280px}
.botton_submit {border:0;background:#ed5736;height:31px;width:100px;text-align:center;line-height:31px;font-family:"Microsoft YaHei";font-size:14px;color:#fff;cursor:pointer;border-radius:4px; margin-right:10px}
</style>
<div id="rightTop">
  <ul class="subnav">
     <li><a class="<?php if ($_GET['act'] == 'addwuliu'): ?>btn0<?php else: ?>btn1<?php endif; ?>" href="index.php?app=kd_wuliu&act=addwuliu">单号录入</a></li>
     <li><a class="<?php if ($_GET['act'] == 'addpiliang'): ?>btn0<?php else: ?>btn1<?php endif; ?>" href="index.php?app=kd_wuliu&act=addpiliang">批量录入</a></li>
  </ul>
</div>
<form action="" method="post" id="form_box">
<table cellspacing="1" width="100%" class="kdorder_add">
  <?php if ($this->_var['act_from']): ?>
  <tr><td colspan="2" style="padding:12px 8px;background:#ffffe5">重要提示：当条件筛选运单过少时可以适当减少输入数量。</td></tr>
  <tr>
      <td align="right" class="title_h1"><em>*</em>条件筛选：</td>
      <td><input type="text" name="zhudanNo" value="<?php echo $this->_var['order_info']['zhudanNo']; ?>" class="inputBorder" placeholder="入仓号/批次号" style="width:100px"/>
      <input type="text" name="baoguoNo" value="<?php echo $this->_var['order_info']['baoguoNo']; ?>" class="inputBorder" placeholder="麻袋号/包裹货号" style="width:155px"/>
      <input type="text" name="baoguanNo" value="<?php echo $this->_var['order_info']['baoguanNo']; ?>" class="inputBorder" placeholder="报关单号" style="width:185px"/>
      <input type="button" id="search_data" class="botton_submit" value="检索数据" style="background:#999;width:80px"/>
      <font color="#999999">（这三个文本框依次对应：主单号批次号、麻袋号包裹货号、报关单号）</font></td>
  </tr>
  <?php else: ?>
  <tr><td colspan="2" style="padding:12px 8px;background:#ffffe5">重要提示：请确认所有运单号都已经录入运单库里了，没有录入运单库的运单号系统会过滤掉。</td></tr>
  <tr>
      <td align="right" class="title_h1"><em>*</em>运单号：</td>
      <td><div style="float:left"><textarea name="yundanhao" class="inputBorder" id="yundanhao" style="width:380px;height:80px"></textarea></div>
      <div style="float:left;padding-left:5px;padding-top:5px;">
      <input type="button" id="search_yundan" class="botton_submit" value="检索有效单号" style="background:#999;"/>
      <label><input name="zidong" type="checkbox" value="1" <?php if ($_GET['zidong'] == '1'): ?>checked="checked"<?php endif; ?> /> 启动自动检索</label><br /><br />
      <font color="#999999">（多个单号间用空格或者回车换行分隔，您只需要一直录入或用条码枪扫描即可）</font>
      </div>
      </td>
  </tr>
  <?php endif; ?>
  <tr>
    <td align="right" class="title_h1"><em>*</em>物流跟踪信息：</td>
    <td><input type="text" id="yudan_text" name="yudan_text" class="inputBorder" value="<?php echo $this->_var['wuliu']['yudan_text']; ?>"/>&nbsp;
    <select id="choosedpl" class="select_class">
	<option value="">快捷物流菜单</option>
    <?php $_from = $this->_var['choos_wuliu']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'list');if (count($_from)):
    foreach ($_from AS $this->_var['list']):
?>
    <option value="<?php echo $this->_var['list']; ?>"><?php echo $this->_var['list']; ?></option>
    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
    </select>
    </td>
  </tr>
  <tr>
    <td align="right" class="title_h1">管理员备注：</td>
    <td><textarea name="notes" class="inputBorder" id="notes" style="width:380px;height:40px;font-size:12px" placeholder="该备注不会在前台物流显示。"><?php echo $this->_var['wuliu']['notes']; ?></textarea></td>
  </tr>
  <tr>
    <td align="right" class="title_h1">添加时间：</td>
    <td><input type="text" id="addtime" name="addtime" class="inputBorder" value="<?php echo local_date("Y-m-d H:i:s",$this->_var['wuliu']['addtime']); ?>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/> <font color="#999999">注意：时间要严格按照时间格式修改</font></td>
  </tr>
  <tr>
    <td align="right" class="title_h1">&nbsp;</td>
    <td>
    <input type="submit" name="imgButton" class="botton_submit" value="添加物流" onclick="return Check_form();"/><font color="#999999">（建议先检索数据，确认无误后再添加物流，否则系统会自动过滤无效单号）</font>
    </td>
  </tr>  
  <tbody id="show_axja" style="display:none">
  <tr>
    <td colspan="2">&nbsp;</td>
    </tr>  
  <tr>
    <td>&nbsp;</td>
    <td><font color="#999999">（无效单号可以复制保存到记事本，添加对应的运单资料后再重新添加物流）</font></td>
  </tr>      
  <tr>
    <td align="right" valign="top" class="title_h1">无效运单号：</td>
    <td id="wuxiaodanhao" style="font-size:14px"></td>
  </tr> 
  <tr>
    <td align="right" valign="top" class="title_h1">有效运单号：</td>
    <td id="youxiaodanhao" style="font-size:14px;word-break: break-all; word-wrap:break-word;"></td>
  </tr>  
  </tbody>    
</table>
</form>
<iframe name="right" id="rightMain" src="" frameborder="0" scrolling="auto" width="100%" allowtransparency="true" style="display:none"></iframe>
<script language="javascript" type="text/javascript">
//sumbit form
function Check_form() {
  if ($("#yudan_text").val() == "") {alert("快递物流跟踪信息不能为空");$("#yudan_text").focus(); return false;}
  $("#form_box").submit();
}
$(document).ready(function () {
  $("#choosedpl").change(function(){
	if ($(this).get(0).selectedIndex != 0) {
	  $("#yudan_text").val($(this).val()).focus();
	  $(this).get(0).selectedIndex = 0;
	}
  });
  $("#search_data").click(function(){
	  var zhudanNo = $("input[name='zhudanNo']").val(),baoguoNo = $("input[name='baoguoNo']").val(),baoguanNo = $("input[name='baoguanNo']").val();page = $("input[name='baoguanNo']").val();
	  if (zhudanNo=="" && baoguoNo=="" && baoguanNo==""){alert("入仓号/批次号、麻袋号/包裹货号、报关单号至少要填写一项");$("input[name='zhudanNo']").focus(); return false;}
	  $("#rightMain").css("display","block");
	  $("#rightMain").attr("src","index.php?app=kd_wuliu&act=ajax_list&zhudanNo="+zhudanNo+"&baoguoNo="+baoguoNo+"&baoguanNo="+baoguanNo+"");
  });
  $("#search_yundan").click(function(){
	  var yundanhao = $("#yundanhao").val();
	  if (yundanhao==""){alert("请输入运单号");$("input[name='zhudanNo']").focus(); return false;}
	  $.get("index.php", {"app":"kd_wuliu", "act":"ajax_yundan", "yundanhao": yundanhao},function(result){
		  var objson = eval("("+ result +")");
		  if(objson.status=='OK'){
			  $("#show_axja").show();
			  $("#youxiaodanhao").html(objson.result);
			  $("#wuxiaodanhao").html(objson.empty_list);
		  }else{
			  alert("没有检索到有效单号，可能单号输入有误");
		  }
	  });
  });

  $("#yundanhao").keydown(function(){
   if($("input[name='zidong']").is(':checked')===true)
   {
	  if(!e) var e = window.event; 
	  if(e.keyCode==13 || e.keyCode==32){
		  var yundanhao = $("#yundanhao").val();
		  if (yundanhao==""){alert("请输入运单号");$("input[name='zhudanNo']").focus(); return false;}
		  $.get("index.php", {"app":"kd_wuliu", "act":"ajax_yundan", "yundanhao": yundanhao},function(result){
			  var objson = eval("("+ result +")");
			  if(objson.status=='OK'){
				  $("#show_axja").show();
				  $("#youxiaodanhao").html(objson.result);
				  $("#wuxiaodanhao").html(objson.empty_list);
			  }else{
				  alert("没有检索到有效单号，可能单号输入有误");
			  }
		  });
	  }
   }
  });
});
</script>
<?php echo $this->fetch('footer.html'); ?>
<?php endif; ?>